<?php
/**
 * Created by PhpStorm.
 * User: 低调
 * Date: 2018/5/25
 * Time: 23:32
 */
//删除 kind = 1   隐藏 kind = 0  显示 kind =2
include("../connectdb.php");
$id = $_GET['id'];
$kind = $_GET['kind'];
if($kind==1 and $id>0){
    $sql ="DELETE  FROM Article WHERE id='$id'";
    if(mysqli_query($conn,$sql)){
        echo "<script>alert('删除成功');location.href='articleList.php';</script>";
    }
    else
        echo "<script>alert('删除失败');location.href='articleList.php';</script>";
}
elseif($kind==0 and $id>0){
    $sql = "UPDATE Article SET status=2 WHERE id='$id'";
    if(mysqli_query($conn,$sql)){
        echo "<script>alert('已隐藏');location.href='articleList.php';</script>";
    }
    else
        echo "<script>alert('失败');location.href='articleList.php';</script>";
}
elseif($kind==2 and $id>0){
    $sql = "UPDATE Article SET status=1 WHERE id='$id'";
    if(mysqli_query($conn,$sql)){
        echo "<script>alert('已公开');location.href='articleList.php';</script>";
    }
    else
        echo "<script>alert('失败');location.href='articleList.php';</script>";
}
else echo "<script>alert('非法操作');location.href='index.php';</script>";